#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N = 2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
ll n;
//4,6都为偶,如果n是奇怎么都不可能
void solve()
{
	sld(n);
	if (n & 1 || n == 1 || n == 2)
	{
		puts("-1"); return;
	}
	//if(!(n%4)) mx=n/4;
	else
	{
		//mi
		ll b = n / 6;
		ll a = (n - b * 6) / 4;
		if (n-a*4-b*6==2)//此时的n是偶数,那么一定剩下2
		{
			b--;
			a+=2;
		}
		cout<<a+b<<" ";
		//mx
		ll a2 = n / 4;
		ll b2 = (n - a2 * 4) / 6;
		if (n-a2*4-b2*6==0)//最后剩余2
		{
			a2--;
			b2++;
		}
		pld(a2 + b2); puts("");
	}

}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}